
var app=getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    gameInfo:{},
    currtab: 0,
    swipertab: [{
      name: '我的订单',
      index: 0
    }, {
      name: 'xxx',
      index: 1
    }, {
      name: 'xxx',
      index: 2
    }],
    deal_goods: {}
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this
    that.setData({
      gameInfo:app.globalData.gameImage
    })
  
    wx.request({
      url: app.globalData.url + 'selectDeal_GoodsAction',
      data: {
        userId: app.globalData.userInfoList.userId,
      },

      success(res) {
        that.setData({
          deal_goods: res.data
        })
      }


    })


  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    // 页面渲染完成
    this.getDeviceInfo()
    this.orderShow()
  },

  getDeviceInfo: function () {
    let that = this
    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          deviceW: res.windowWidth,
          deviceH: res.windowHeight
        })
      }
    })
  },

  /**
   * @Explain：选项卡点击切换
   */
  tabSwitch: function (e) {
    var that = this
    if (this.data.currtab === e.target.dataset.current) {
      return false
    } else {
      that.setData({
        currtab: e.target.dataset.current
      })
    }
  },

  tabChange: function (e) {
    this.setData({
      currtab: e.detail.current
    })
    this.orderShow()
  },

  orderShow: function () {
    let that = this
    switch (this.data.currtab) {
      case 0:
        that.alreadyShow()
        break
      case 1:
        that.waitPayShow()
        break
      case 2:
        that.lostShow()
        break
    }
  },
  alreadyShow: function () {
    this.setData({
      alreadyOrder: [{
          username: "猪皮1",
          dealid: "777777",
          state: "交易成功",
          name: "账号1",
          detail: "描述描述",
          url: "../image/订单.png",
          money: "132",
          time: "2021-3-5"
        },
        {
          username: "猪皮11",
          dealid: "777777",
          state: "交易成功",
          name: "账号2",
          detail: "描述描述描述",
          url: "../image/订单.png",
          money: "205",
          time: "2021-3-5"
        }
      ]
    })
  },

  waitPayShow: function () {
    this.setData({
      waitPayOrder: [{
        username: "猪皮2",
        dealid: "777777",
        state: "待付款",
        name: "账号3",
        detail: "描述描述描述",
        url: "../image/订单.png",
        money: "186",
        time: "2021-3-5"
      }],
    })
  },

  lostShow: function () {
    this.setData({
      lostOrder: [{
        username: "猪皮3",
        dealid: "777777",
        state: "已取消",
        name: "账号4",
        detail: "描述描述",
        url: "../image/订单.png",
        money: "122",
        time: "2021-3-5"
      }],
    })
  },
  submit: function (e) {
    wx.navigateTo({
      url: '../goodscore/goodscore',
    })
  }

})